const Base = require('./base.js');

module.exports = class extends Base {
    async indexAction() {
        // return this.display();
        let records;

        const userInstance=think.mongoose('Administrator',{},'admin');
        // const userInstance=think.mongoose('Administrator');
        records= await userInstance.find({}).exec();

        // records = JSON.parse(JSON.stringify(records));
        // records.map(function(item){
        //     return item.toJSON({ virtuals: true });
        // });
        //


        // console.log(records);
        // records = [
        //     {
        //         id:1,
        //         username: 'name-1',
        //         email: 'zengqs@gzpyp.edu.cn'
        //     },
        //     {
        //         id:2,
        //         username: 'name-2',
        //         email: 'zengqs@gzpyp.edu.cn'
        //     },
        //     {
        //         id:3,
        //         username: 'name-3',
        //         email: 'zengqs@gzpyp.edu.cn'
        //     },
        // ];

        // console.log(records);
        // // console.log(typeof records);
        // for (let item of records){
        //     console.log(item.toString());
        //     console.log(`${item._id},${item.username},${item.email}`);
        // }


        this.assign({
            title: 'Thinkjs V3.2',
            records: records,
        });



        // const assignedData= this.assign();
        // console.log(assignedData.records);
        // console.log(typeof assignedData.records);

        return this.display('home/index/index');
    }
};
